var util = require('../../../utils/util.js');
var api = require('../../../config/api.js');
var app = require('../../../app.js');
var user = require('../../../services/user.js');
var wxcache = require('../../../utils/wxcache.js');


var app = getApp();

Page({
  data: {
    couponIntroduce_info:null,
  },
  onLoad: function (options) {
    //加载优惠券
    this.getAllCouponIntroduce();
  },
  onReady: function () {

  },
  onShow: function () {

  },
  onHide: function () {
    // 页面隐藏

  },
  onUnload: function () {
    // 页面关闭
  },

  getAllCouponIntroduce: function () {
    //获取用户所有优惠券
    var that =this;
    user.checkLogin().then(res => {
        //用户已登录
        var uid = wxcache.get("userInfo").id
        util.request(api.CouponsIntroduceQuery).then(function (res) {
          console.log(res.responseBody)
          that.setData({
            couponIntroduce_info: res.responseBody
          });
        })
    }).catch(() => {
        //用户未登录
        wx.showModal({
          title: '信息',
          content: '请登录小程序',
          showCancel: false
        });
    });
  },
  coupon_sn:function(e){
    var num = e.detail.value;
    this.setData({
      coupon_sn:num
    });
  }
 
})